<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数组去重</title>
</head>
<body>
    
    <script>

/*       // 对象去重法 
      Array.prototype.unique = function () {
          let obj = {};
          for(let i=0;i<this.length;i++){
              let item = this[i];
              if(typeof obj[item] != 'undefined'){
                  this[i] = this[this.length - 1];
                  this.length --;
                  i --;
              }
              obj[item]=item;
          }
          obj=null;
          return this;
      };

      console.log([9,10,11,12,10,11,12,10,10,13,14,15,15,10,11,16,17,18,16,10].unique().sort((a,b) => a-b));


      // set方法
      function fn (a) {
          return new Set(a);
      };

      console.log(Array.from(fn([9,10,11,12,10,11,12,10,10,13,14,15,15,10,11,16,17,18,16,10]))); */

      {

        let ary = [9,10,11,12,10,11,12,10,10,13,14,15,15,10,11,16,17,18,16,10];

        Array.prototype.createSet = function () {
            let _this = new Set(this);
            return Array.from(_this);
        }

        console.log(ary.createSet());

      }
      

      
    </script>
</body>
</html>